package com.starblink.store.recommend.adapter

import android.view.ViewGroup
import com.starblink.android.basic.adapter.BaseVH
import com.starblink.android.basic.aroute.CommonRoute
import com.starblink.android.basic.ext.click
import com.starblink.android.basic.sensorsdata.extension.businessSuffixId
import com.starblink.android.basic.sensorsdata.extension.trackData
import com.starblink.android.basic.sensorsdata.spm.cfg.SpmElementDef
import com.starblink.android.basic.sensorsdata.spm.cfg.SpmPageDef
import com.starblink.rocketreserver.fragment.MerchantWebVOF

class MyFavoriteStoresHolder(
    val parent: ViewGroup,
    val pageTrackTag: String,
) : BaseVH<MerchantWebVOF>(StoreHeadView(parent.context)) {

    private val cardView = itemView as StoreHeadView

    override fun onBind(merchat: MerchantWebVOF, position: Int) {
        cardView.bindPost(merchat, position)
        itemView.click {
            CommonRoute.startStoreDetail(parent.context, merchat.id)
        }
        itemView.trackData(
            page = SpmPageDef.SubscribeRecommendStoresPage,
            element = SpmElementDef.ELE_33032,
            params = mapOf("merchantName" to "${merchat.merchantName}"),
            businessSuffixID = businessSuffixId(merchat)
        )
    }
}